function Rectangle(origin, width, height) {
    this.origin = origin;
    this.width = width;
    this.height = height;
    this.center = new Point(this.origin.x + (this.width / 2), this.origin.y + (this.height / 2));
}

Rectangle.prototype = {
    constructor: Rectangle,
    getIntersectionFromCenterToPoint: function(point){

        var tLVertice = this.origin,
            tRVertice = new Point(this.origin.x + this.width , this.origin.y),
            bLVertice = new Point(this.origin.x, this.origin.y + this.height),
            bRVertice = new Point(this.origin.x + this.width, this.origin.y + this.height);

        var edges = [
            new Line(tLVertice, tRVertice),
            new Line(tRVertice, bRVertice),
            new Line(bRVertice, bLVertice),
            new Line(bLVertice, tLVertice)
        ];

        var joiner = new Line(this.center, point);

        for (var i = edges.length - 1; i >= 0; --i){
            var intersection = edges[i].getIntersection(joiner);
            if (intersection !== null){
                return intersection;
            }
        }

        return null;
    }
}